<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">
                    <button class="layui-btn" onclick="xadmin.open('添加会员分组','/admin/group/create',600,500)"><i class="layui-icon"></i>添加</button>
                </div>
                <div class="layui-card-body ">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>名称</th>
                            <th>状态</th>
                            <th>操作</th>
                        </thead>
                        <tbody>
                        {{range .list}}
                            <tr>
                                <td>{{.Id}}</td>
                                <td>{{.Name}}</td>
                                <td>
                                    {{if compare .Status 1 }}
                                        正常
                                    {{else if compare .Status 2}}
                                        禁用
                                    {{end}}
                                </td>
                                <td>
                                    <button class="layui-btn layui-btn layui-btn-xs"  onclick="xadmin.open('编辑用户','/admin/group/edit/{{.Id}}',600,450)" ><i class="layui-icon">&#xe642;</i>编辑</button>
                                    <button class="layui-btn-danger layui-btn layui-btn-xs"  onclick="del(this,{{.Id}})"href="javascript:;" ><i class="layui-icon">&#xe640;</i>删除</button>
                                </td>
                            </tr>
                        {{end}}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var form = layui.form;

        //执行一个laydate实例
        laydate.render({
            elem: '#start', //指定元素
            type: 'datetime'
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end', //指定元素
            type: 'datetime'
        });
    })
    /*删除*/
    function del(obj,id){
        layer.confirm("确认要执行此操作吗？",function(index){
            request_get('/admin/group/destroy/'+id).then(function (data) {
                window.location.reload()
            },function (error) {
                msg_error(error.msg)
            })
            layer.close(index)
        })
    }
</script>
